package top.glkj.hms.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;

/**
 * @author : xgl
 * @version : 0.0.1
 * @date :2020/12/22 3:21
 * 员工
 */
@Entity
@Table(name = "hms_employee")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Employee extends BaseEntity{
    /**
     * 员工号
     */
    @Column(name = "code")
    private int code;
    @OneToOne(targetEntity = User.class,cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    private User user;
    @OneToOne(targetEntity = Role.class,cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "role_id", referencedColumnName = "id")
    private Role role;
    public Employee(Long id) {
        super(id);
    }
}
